﻿/* 
 *  <copyright file="WorldMap.cs" company="Wesley Jowitt">
 *  
 *  SobrietyEngine: Copyright (c) 2011 Wesley Jowitt
 *  
 *  This software is distributed under a software license.
 *   * As of the creation time of this file, the license in use is the Microsoft Permissive License (Ms-PL) 
 *    * The license can be viewed at:
 *     * License.Txt in the root folder of this project
 *      * http://sobrietyengine.codeplex.com/license
 *       * http://www.microsoft.com/opensource/licenses.mspx
 *       
 *  </copyright>
 *   */

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using SEGameExample.Kludge;
using SobrietyEngine.Actor;
using SobrietyEngine.Scene;
using SobrietyEngine.Screens;


namespace SEGameExample.Screens
{
    class WorldMap : BaseLevel
    {
        public WorldMap():base("WorldMapScene")
        {
        }

        public override void Initialize()
        {
            base.Initialize();
     
            GraphicsDevice gDevice = ScreenManager.GraphicsDevice;

            //need to create a series of pathnodes to create our Mario3 style world map
            //start simple, with a square for now, using unidirectional path nodes
            //this will change once i solidify the plan to create either a better set of path components
            //or a pathfinding service

            Vector2[] map = new Vector2[] { 
                new Vector2(0, 0), new Vector2(3, 0), 
                new Vector2(3, 3), new Vector2(0, 3) 
            };

            String[] nodeDesc = new String[] {
                "Test Level 1: 2.5D Platformer Test (Available)", "Test Level 2: Actor Template Platformer (Available)",
                "Test Level 3: Asteroids Test (Unavailable)", "Test Level 4: FPS Test (Unavailable)"
            };

            Vector2 descPos = new Vector2( ScreenManager.FullScreenViewport.Width / 3, 10);

            List<IActor> nodeActors = WorldMapSpawner.CreateWorldMapNodes(Scene, map, nodeDesc, descPos, gDevice);

            //make the player actor
            IActor actor = WorldMapSpawner.CreatePlayer(Scene, PlayerOne.Guid, nodeActors[0]);

            //create 3D Scene camera (eventually there will be a 3D mesh servin as the map background)
            IActor cam3D = GameplaySpawner.OrthoFollowActorCam3D(Scene, ScreenManager.FullScreenViewport, ScreenManager.GraphicsDevice, nodeActors[0].Guid);

            //create a 2D gui/hud camer
            //IActor cam2D = GUISpawner.Camera2D(Scene, ScreenManager.FullScreenViewport);
            IActor cam2d = SobrietyEngine.Actor.Builders.Cameras.GuiCameraBldr.Build(Scene, ScreenManager.FullScreenViewport);

            //add a bit of help text
            SobrietyEngine.Actor.Builders.GUI.Text2D.Build(Scene, new Vector2(0, ScreenManager.FullScreenViewport.Height / 2),
                "This is a crappy world map. \n Push Left thumbstick towards node to move \n Push (X) button to enter level");

            SceneGameService.Enabled = true;
            SceneGameService.Scenes[SceneName].EnableControllers();            
        }

    }
}